package com.marvels.approve.loan.service.impl;

import com.marvels.approve.loan.dao.McamLoanBxCompanyMapper;
import com.marvels.approve.loan.dto.McamLoanBxCompanyDTO;
import com.marvels.approve.loan.service.McamLoanBxCompanyService;
import com.marvels.common.exception.MarvelsBusinessException;
import com.marvels.common.utils.DateUtils;
import com.marvels.common.utils.MarvelsLogUtil;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

@Service
public class McamLoanBxCompanyServiceImpl implements McamLoanBxCompanyService {
	@Autowired
	private McamLoanBxCompanyMapper mcamLoanBxCompanyMapper;
	@Override
	public List<McamLoanBxCompanyDTO> selectBxCompanyList() throws MarvelsBusinessException {
		return mcamLoanBxCompanyMapper.selectBxCompanyList();
	}
	@Override
	public List<Map<String, Object>> selectBxCompanyListOuter() throws MarvelsBusinessException {
		MarvelsLogUtil.getInstance().info("开始执行查询保险公司列表======》》》》》");
		List<McamLoanBxCompanyDTO> list= this.selectBxCompanyList();
		List<Map<String, Object>> result = new LinkedList<Map<String, Object>>();
		if(CollectionUtils.isEmpty(list)){
			MarvelsLogUtil.getInstance().info("返回查询保险公司列表======》》》》》"+result);
			return result;
		}
		for (McamLoanBxCompanyDTO dto : list) {
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("type_id", "BX_PREMIUM");
			map.put("id",dto.getBxCompanyCode());
			map.put("name",dto.getBxCompanyName());
			map.put("desc_",dto.getBxSort().toString());
			map.put("order_","");
			map.put("isvalid","Y");
			map.put("lastupdater",dto.getUpdatedBy());
			map.put("lastupdatetime",DateUtils.getDateYYYYMMDDHHMMSS(dto.getUpdatedDate()));
			map.put("name_local","");
			map.put("desc_local","");
			map.put("isChannel","");
			result.add(map);
		}
		MarvelsLogUtil.getInstance().info("返回查询保险公司列表======》》》》》"+result);
		return result;
	}

}
